from google.appengine.ext.webapp import template
from google.appengine.api import memcache
import os, sys, logging
from libs import simplejson as json, utils

from libs import utils
from app import abstract, models, config

class Action(abstract.Action):
    
    def _render(self, view, params = None):
        
        file = "views/" + view + ".html"
            
        path = os.path.join(os.path.dirname(__file__), file)
        self.response.out.write(template.render(path, params))
    
    def render(self, params = None):
        
        file = config.module + "/views/" + config.action + ".html"
            
        path = os.path.join(os.path.dirname(__file__), file)
        self.response.out.write(template.render(path, params))
        
    def jsonp(self, data, callback):

        self.response.headers['Content-Type'] = ' text/javascript'
        
        data = json.dumps(data)
        
        if callback != "":
            data = callback + "(" + data + ")"
        
        self.response.out.write(data)

        
